package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.positiontype.BasePositionTypePageRequest;
import com.mes.cloud.api.dto.request.positiontype.BasePositionTypeRequest;
import com.mes.cloud.api.dto.request.positiontype.BatchEnableFlagRequest;
import com.mes.cloud.api.dto.response.positiontype.BasePositionTypeDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.BasePositionTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author wxm
 * @version 2019-08-08 15:16:52
 * @email xiaomin.wu1@pactera.com
 */
@Api(tags = "岗位类型", value = "岗位类型接口")
@RestController
@RequestMapping(value = "/basePositionType")
public class BasePositionTypeController  {

    private BasePositionTypeService basePositionTypeService;

    @Autowired
    public BasePositionTypeController(BasePositionTypeService basePositionTypeService) {
        this.basePositionTypeService = basePositionTypeService;
    }

    /**
     * 功能: 岗位类型分页查询
     *
     * @param pageRequest
     * @return JsonResult<CommPager<BasePositionTypeDto>>
     */
    @ApiOperation(value = "岗位类型分页查询", notes = "岗位类型分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<BasePositionTypeDto>> pageList(@Valid @RequestBody BasePositionTypePageRequest pageRequest) {
        return basePositionTypeService.pageList(pageRequest);
    }

    /**
     * 功能: 岗位类型查询所有
     *
     * @param basePositionTypeRequest
     * @return JsonResult<List<BasePositionTypeDto>>
     */
    @ApiOperation(value = "岗位类型查询所有", notes = "岗位类型查询所有")
    @PostMapping(value = "/list")
    public JsonResult<List<BasePositionTypeDto>> list(@RequestBody BasePositionTypeRequest basePositionTypeRequest) {
        return basePositionTypeService.list(basePositionTypeRequest);
    }

    /**
     * 功能: 岗位类型新增
     *
     * @param basePositionTypeRequest
     * @return JsonResult
     */
    @ApiOperation(value = "岗位类型新增", notes = "岗位类型新增")
    @PostMapping(value = "/add")
    public JsonResult add(@Valid @RequestBody BasePositionTypeRequest basePositionTypeRequest) {
        return basePositionTypeService.insert(basePositionTypeRequest);
    }

    /**
     * 功能: 岗位类型修改
     *
     * @param basePositionTypeRequest
     * @return JsonResult
     */
    @ApiOperation(value = "岗位类型修改", notes = "岗位类型修改")
    @PostMapping(value = "/update")
    public JsonResult update(@Valid @RequestBody BasePositionTypeRequest basePositionTypeRequest) {
        return basePositionTypeService.update(basePositionTypeRequest);

    }

    /**
     * 功能: 批量启用禁用
     *
     * @param batchEnableFlagRequest
     * @return JsonResult
     */
    @ApiOperation(value = "批量启用禁用", notes = "批量启用禁用")
    @PostMapping(value = "/batchEnableFlag")
    public JsonResult batchEnableFlag(@Valid @RequestBody BatchEnableFlagRequest batchEnableFlagRequest) {
        return basePositionTypeService.batchEnableFlag(batchEnableFlagRequest);
    }

    /**
     * 功能: 岗位类型删除
     *
     * @param id
     * @return JsonResult
     */
    @ApiOperation(value = "岗位类型删除", notes = "岗位类型删除")
    @ApiImplicitParam(paramType = "Long", name = "id", value = "岗位类型主键", required = true)
    @GetMapping(value = "delete/{id}")
    public JsonResult delete(@PathVariable String id) {
        return basePositionTypeService.delete(id);

    }

    /**
     * 功能: 岗位类型查看详情
     *
     * @param id
     * @return JsonResult
     */
    @ApiOperation(value = "岗位类型查看详情", notes = "岗位类型查看详情")
    @ApiImplicitParam(paramType = "Long", name = "id", value = "岗位类型主键", required = true)
    @GetMapping(value = "get/{id}")
    public JsonResult get(@PathVariable String id) {
        return basePositionTypeService.get(id);
    }

    /**
     * 功能: 岗位类型禁用启用
     *
     * @param id
     * @param enableFlag
     * @return JsonResult
     */
    @ApiOperation(value = "岗位类型禁用启用", notes = "岗位类型禁用启用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true),
            @ApiImplicitParam(name = "enableFlag", value = "状态", required = true),
    })
    @GetMapping(value = "/updateEnableFlag/{id}/{enableFlag}")
    public JsonResult updateEnableFlag(@PathVariable String id, @PathVariable String enableFlag) {
        return basePositionTypeService.updateEnableFlag(id, enableFlag);
    }
}
